'use strict';
const UniSubscribemsg = require('uni-subscribemsg');
// 初始化实例
let uniSubscribemsg = new UniSubscribemsg({
	dcloudAppid: "__UNI__1D704FE", // https://dev.dcloud.net.cn/pages/app/list
	provider: "weixin-mp",
});
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ',context, event.touser,event.template_id);
	// 发送订阅消息
	let res = await uniSubscribemsg.sendSubscribeMessage({
		touser: event.touser, // 用户openid
		template_id: event.template_id, // 消息模板id
		page: "pages/index/index", // 小程序页面地址
		miniprogram_state: "formal", // 跳转小程序类型：developer为开发版；trial为体验版；formal为正式版；默认为正式版
		lang: "zh_CN",
		data: event.data
	});
	//返回数据给客户端
	return res
};
